Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store calibration results #16

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

RNGIllSkillz
Copy link
Contributor

Implemented a command TOOL_CALIBRATE_STORE_TOOL_OFFSET that will append results in to a txt file at printer_data/config/tools_calibrate_results/

Command TOOL_CALIBRATE_STORE_TOOL_OFFSET will save calibration result in to a file
@VIN-y
Copy link
Contributor

VIN-y commented Jun 22, 2024

Hi guys,

I have been on the fence about how useful this feature is for for a while. Now that I have had a proper thought about. This might actually be pretty handy for a dynamic hardware config, like MissChanger, where the multi-tool-head hardware is designed to be quickly removable.

At the moment, even if I can disconnect all the hardware in less than a minute, I will still need to manually go to the printer.cfg to comment out the tool-head profile, and move the PID and offsets another file. Then, I will have to do all of that in reverse when I want to put them back... This gets old really quickly.

In this context, to have the data being saved in a separate file, from which I can use a script to automatically re-import into printer.cfg, is pretty helpful. Nevertheless, this is not a universal problem for all printer, and the feature set might need to be expanded to do have the automatic re-import function. All of that code will not be relevant to non-dynamic hardware configs, thus will only serve as potential sources of bugs for them.

Therefore, I propose that we put what you got here, and any feature that related to data management into a separate .py file. So, we can have the features, but in an isolated form.

@joseph-greiner
Copy link

An option that could be used is a [save_variables] file in Klipper, from each of the tool_calibrate_tool_offset call a separate macro to store and update the offsets:

[save_variables]
filename: ~/printer_data/config/offset-variables.cfg

[gcode_macro save_offsets_to_disk]
gcode:
{% set svv = printer.save_variables.variables %}
{% set tool = params.T|default(1)|int %}
SAVE_VARIABLE VARIABLE=t{tool}_offset_x VALUE=printer.tools_calibrate.last_x_result|round(6)}
SAVE_VARIABLE VARIABLE=t[tool}_offset_y VALUE=printer.tools_calibrate.last_y_result|round(6)}
SAVE_VARIABLE VARIABLE=t{tool}_offset_z VALUE=printer.tools_calibrate.last_z_result|round(6)}

Then you can load them from the file at run time in a macro:
{% set svv = printer.save_variables.variables %}
{% set load_x_offset = svv.t1_offset_x|float %}
{% set load_y_offset = svv.t1_offset_y|float %}
{% set load_z_offset = svv.t1_offset_z|float %}

And adjust your offsets from there.

@russiancatfood
Copy link

Same idea, but using the last_result to set Gcode macro variables (since everything in IDEX land is hacked together with macros)

SET_GCODE_VARIABLE MACRO=DC_VARS VARIABLE=offset_x VALUE={printer.tools_calibrate.last_x_result|round(6)}
SET_GCODE_VARIABLE MACRO=DC_VARS VARIABLE=offset_y VALUE={printer.tools_calibrate.last_y_result|round(6)}
SET_GCODE_VARIABLE MACRO=DC_VARS VARIABLE=offset_z VALUE={printer.tools_calibrate.last_z_result|round(6)}

@VIN-y
Copy link
Contributor

VIN-y commented Jun 24, 2024

[save_variables]

I actually totally forgot that existed. Thanks.
I will see what I can do with it.

@VIN-y
Copy link
Contributor

VIN-y commented Jun 26, 2024

I found it.
There is a macro called [gcode_shell_command] that can be installed via KIAUH, which allows me to run bash commands. I just use that to toggle the config for multi-toolhead and single-toolhead.

Only wait if there's an actual temp change, otherwise we will be waiting for no reason.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants